﻿@model PauseSiteSettingsEditModel
@{
    ViewData["Title"] = new string[] { "暂停站点" };
    TempData["subMenu-check"] = new string[] { "Tool", "PauseSiteSettings" };

}

<div class="row tn-page-heading tn-mb-10">
    <div class="col-lg-12">
        <h3>暂停站点</h3>
    </div>
</div>
<div class="tn-box tn-box-v1">
    @using (Html.BeginForm("SavePauseSiteSettings", "ControlPanel", FormMethod.Post, new { @class = "form-horizontal tn-form-validation", @id = "EditPauseSiteSetting" }))
    {
        <div class="form-group">
            @Html.LabelFor(model => model.IsEnable, new { @class = "col-xs-4 control-label", @style = "width:120px" })
            <div class="col-xs-4 form-control-static">
                @Html.RadioButtonFor(model => model.IsEnable, true) 运行中&nbsp;
                @Html.RadioButtonFor(model => model.IsEnable, false)  暂停
            </div>
        </div>
       
        <div id="stopSite" @(Model.IsEnable ? "style=display:none" : "" )>

            <div class="form-group">
                @Html.LabelFor(model => model.PausePageType, new { @class = "col-xs-4 control-label", @style = "width:120px" })
                <div class="col-xs-4 form-control-static">
                    @Html.RadioButtonFor(model => model.PausePageType, true) 暂停页面类型&nbsp;
                    @Html.RadioButtonFor(model => model.PausePageType, false)  外链

                </div>
            </div>

            <div id="wailian" class="form-group"  @(Model.PausePageType ? "style=display:none" : "" )>
                @Html.LabelFor(model => model.PauseLink, new { @class = "col-xs-2 control-label", @style = "width:120px" })
                <div class="col-xs-4">
                    @Html.TextBoxFor(n => n.PauseLink, new { @class = "form-control", @placeholder = "http://" })
                </div>
            </div>
            <div id="gonggao" class="form-group"   @(!Model.PausePageType ? "style=display:none" : "" )>
                @Html.LabelFor(model => model.PauseAnnouncement, new { @class = "col-xs-2 control-label", @style = "width:120px" })
                <div class="col-xs-4">
                    @Html.TextAreaFor(n => n.PauseAnnouncement, new { @class = "form-control", @placeholder = "暂停公告" })
                    <span class="help-block">可以输入Html标签</span>
                </div>
            </div>
        </div>

        <hr />
        <div class="form-group">
            <div class="col-xs-8">
                <label for="" class="col-xs-2 control-label" style="width:120px"></label>
                <button id="primary" type="button" class="btn btn-primary btn-submit tn-btn-wp">确定</button>
               
            </div>
        </div>
                        }


</div>
<script>
    require(['jquery'], function () {
        $("[name='IsEnable']").change(function myfunction() {
            if ($(this).val() == "False") {
                $("#stopSite").show();
            }
            else {
                $("#stopSite").hide();
            }
        });
        $("[name='PausePageType']").change(function myfunction() {
            if ($(this).val() == "False") {
                $("#wailian").show();
                $("#gonggao").hide();
            }
            else {
                $("#gonggao").show();
                $("#wailian").hide();
            }
        });
        $("#primary").click(function myfunction() {

            if ($("[name='IsEnable']:checked").val() == "False" && $("[name='PausePageType']:checked").val() == "False" && $("#PauseLink").val() == "") {
                layer.msg("外链不能为空", {
                    icon: 2
                });
                return false;
            }

            $.post("@CachedUrlHelper.Action("SavePauseSiteSettings", "ControlPanel")", $("#EditPauseSiteSetting").serialize(), function myfunction(data) {
                if (data.state) {
                    layer.msg(data.msg, {
                        icon: 1
                    });
                }
                else {
                    layer.msg("设置失败", {
                        icon: 2
                    });
                }
            })
        })
    });
</script>